Skip to content

Use Go regexp for autoImportSpecifierExcludeRegexes, remove regexp2#3245

Merged
jakebailey merged 1 commit intomainfrom
jabaile/remove-regexp2-module-specifiers
Mar 26, 2026
Merged

Use Go regexp for autoImportSpecifierExcludeRegexes, remove regexp2#3245
jakebailey merged 1 commit intomainfrom
jabaile/remove-regexp2-module-specifiers

Conversation

@jakebailey
Copy link
Copy Markdown
Member

@jakebailey jakebailey commented Mar 26, 2026

With #2407 merged, autoImportSpecifierExcludeRegexes is the only place we ever construct a regex derived from user input. We do that with regexp2 today, to be ECMAScript compatible.

However, I just don't think people should be sticking anything complicated in there. And indeed, on GitHub, only one preference uses a regex that is not within re2 syntax: https://github.com/reformcollective/reform-next-starter/blob/c75b23a1be762ea42ede3edf3e36d4fe1141eb43/.vscode/settings.json

I think we should drop the regexp2 dep and just use Go's regexp package. This is a break for sure, but, I don't think this one feature warrants shipping an entirely separate regex engine.

Shaves 368K off our binary, so that's something I guess.

Copilot AI review requested due to automatic review settings March 26, 2026 18:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the regexp2 dependency from the TypeScript-Go codebase by switching autoImportSpecifierExcludeRegexes matching to Go’s standard regexp (RE2) engine in internal/modulespecifiers, aligning with the recent direction from #2407 to reduce/avoid regexp2 usage.

Changes:

  • Replace regexp2 compilation/matching with Go regexp, including support for /.../i case-insensitive patterns.
  • Remove github.com/dlclark/regexp2 from go.mod/go.sum.
  • Remove the regexp2 license block from NOTICE.txt.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
internal/modulespecifiers/util.go Switch cached compilation/matching to regexp and map /.../i to RE2 via an inline case-insensitive wrapper.
go.mod Drop the direct regexp2 dependency.
go.sum Remove regexp2 checksums.
NOTICE.txt Remove third-party notice entry for regexp2.

@jakebailey jakebailey added this pull request to the merge queue Mar 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 26, 2026
@jakebailey jakebailey added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit d6517bf Mar 26, 2026
41 of 43 checks passed
@jakebailey jakebailey deleted the jabaile/remove-regexp2-module-specifiers branch March 26, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants